package webflux2.util;

import webflux2.exception.CheckException;

import java.util.stream.Stream;

public class CheckUtil {

    /**
     * 校验名字，不成功抛出校验异常
     * @param name
     */

    private static final String[] INVALID_NAMES = {"admin","administrators"};

    public static void checkName(String value) {
        Stream.of(INVALID_NAMES).filter(name -> name.equalsIgnoreCase(value))
                .findAny().ifPresent(name ->{
                    throw new CheckException("name",value);
        });
    }
}
